﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="coreExample.aspx.cs" Inherits="DarrenSoft.UI.WebTest.index" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>类库使用示例</title>
     <script src="Scripts/jquery-1.4.2.min.js" type="text/javascript"></script>
     <script src="Scripts/Darren.Core.js" type="text/javascript"></script>
     <script type="text/javascript">
         /**
         * @使用命名空间
         * @Namespace example
         */
             Sw.Namespace("Darren.Controls.DatePicker")
             Darren.Controls.render = function() { alert("controlsWidth:200px"); }
             Darren.Controls.DatePicker.render = function() { alert("DatePickerWidth:200px"); }
         /**
         * @构造函数
         * @Construct example
         * @params:object------>注意such as {width:"200"}or {width:"200",height:"100"}
         */
         //添加构造函数
             Darren.Controls.DatePicker = function(objParams) {
                
                 Sw.apply(this, objParams);
             }
         //添加实例方法-----------------参照(1)
             Sw.apply(Darren.Controls.DatePicker.prototype, {
                 print: function() {
                     alert(String.format("width:{0},height:{1}", this.width, this.height));
                 }
             })
         /**
         * @类属性,类实例方法,类静态方法
         * @property method example
         */
         //添加一个颜色属性和一个静态方法show()
             Sw.apply(Darren.Controls.DatePicker.prototype, {
                 color:"#FF0000",
                 show: function() { alert(String.format("this.datePicker.color:{0},但我是调用一个实例方法呵",this.color)); }
             })
         //添加类静态方法
             Darren.Controls.DatePicker.show = function() {
               alert(String.format("this.datePicker.color:{0},我是调用一个静态方法哈", this.color));
           }
         /**
          * @方法重写 
          * @override method example
          */
           Sw.apply(Darren.Controls.DatePicker.prototype, {
               dispose: function() { alert(String.format("this.datePicker.color:{0}", this.color)); }
           })
           //重写dispose方法-*** //方法二可参考类继承部分
           Sw.apply(Darren.Controls.DatePicker.prototype, {
               dispose: function() { alert(String.format("this.datePicker.color:{0},但我已经重写了此方法", this.color)); }
           })
          /**
           * @类继承,以及别名的应用
           * @class extend example
           */
  
            DC = Darren.Controls; //命名空间的别名
            //*******************父类*********************
            //构造方法
            DC.Panel = function(param){
                Sw.apply(this,param);
            }
            DCP =DC.Panel; //类别名
            //演示类实例方法
            Sw.apply(DCP.prototype, {
                name: "my name is panel",
                color: "my color is #FFFFFF",  
                initialize:function(){
                alert(String.format("{0},{1}", this.name, this.color));
                }
            })
            //*******************子类1*********************
            DC.Window = function(param) {
              Sw.apply(this,param);
            }
            DCW = DC.Window;
            //让window 继承panel并重写initialize()方法
            Sw.extend(DCW, DCP, {
            name: "my name is window",
                //大家可以试着注释下面方法重写，就是调用父类的initialize()方法
                initialize: function() {      
                    alert(String.format("{0},{1}我的颜色是我父亲的,但是我的名字改了哦，呵呵", this.name, this.color));
                }
            })
            $(function() {
                //************** 演示***********************
                //**命名空间,别名
                //new Darren.Controls.render();
                //new Darren.Controls.DatePicker.render();
                //**构造函数
                //var datepicker = new Darren.Controls.DatePicker({ width: "200", height: "100" });
                //      datepicker.print();
                //**类属性,类实例方法,类静态方法
                //var datepicker = new Darren.Controls.DatePicker();
                //调用实例方法
                //datepicker.show();
                //调用静态方法
                //Darren.Controls.DatePicker.show();
                //**方法重写
                // var datepicker = new Darren.Controls.DatePicker();
                //调用实例方法
                //datepicker.dispose();
                //**类继承,以及别名的应用
               // var dialog = new DCW();
                //dialog.initialize();
               

            });
        
   
     </script>
</head>
<body>
    <div>
    
    </div>   
</body>
</html>
